// pages/gaoyapeijian/gaoya_item/gaoya_item.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    i:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(app.globalData.gaoya[options.id])
    if(app.globalData.gaoya[options.id].leixing == '电池包'){
      this.setData({
        i:1
      })
    }
    if(app.globalData.gaoya[options.id].leixing == '驱动电机'){
      this.setData({
        i:2
      })
    }
    this.setData({
      item:app.globalData.gaoya[options.id]
    })
  },
  fuzhi(e){
    var that = this
    var k = ""

    if(this.data.i == 0){
      k = that.data.item.diankong.join(',')
    }
    if(this.data.i == 1){
      k = that.data.item.dianchi.join(',')
    }
    if(this.data.i == 2){
      k = that.data.item.qudong.join(',')
    }
    wx.setClipboardData({
      data: "图片路径 :"+ k,
      success() {
        wx.showToast({
          title: '复制成功',
          icon: 'success',
          duration: 1000
        })
      }
    })
  },
  ViewImage(e) {
   if(this.data.i == 0){
    wx.previewImage({
      urls: this.data.item.diankong,
      current: e.currentTarget.dataset.url
    });
   }
   if(this.data.i == 1){
    wx.previewImage({
      urls: this.data.item.dianchi,
      current: e.currentTarget.dataset.url
    });
   }
   if(this.data.i == 0){
    wx.previewImage({
      urls: this.data.item.qudong,
      current: e.currentTarget.dataset.url
    });
   }
  },
  
})